#include <OgreSceneNode.h>
#include "InteractiveObject.h"
#include "application.h"
#include "util.h"

using namespace Ogre;

void InteractiveObject::create(std::string entity_name,Vector3 position, float scale,float yaw, float pitch, float roll)
{
	mEntity=gSceneMgr->createEntity(generateName(),entity_name);
	mNode->attachObject((MovableObject*) mEntity);
	mNode->setPosition(position);
	mNode->yaw(Degree(yaw));
	mNode->pitch(Degree(pitch));
	mNode->roll(Degree(roll));
	mNode->setScale(scale,scale,scale);

}

void InteractiveObject::update(float k)
{

}

void InteractiveObject::init(Vector3 position)
{

}

void Barrel::init(Vector3 position)
{
	float scale=mNode->getScale().x;
	mNode->setScale(scale,scale,scale*0.1);

	NxActorDesc actorDesc;
	NxBodyDesc bodyDesc;
	NxCapsuleShapeDesc capsuleDesc;

	capsuleDesc.height = 2.0f;
	capsuleDesc.radius = 0.5f;
	actorDesc.shapes.pushBack(&capsuleDesc);
	actorDesc.body		= NULL;
	actorDesc.globalPose.t	= NxVec3(position.x, position.y, position.z);

	NxActor *capsuleActor=gScene->createActor(actorDesc); 
	assert(capsuleActor);
}

void ObjectNarrow::init(Vector3 position)
{
	float scale=mNode->getScale().x;
	mNode->setScale(scale,scale,scale);
	mNode->pitch(Degree(180));

	//physics part
/*
	NxActorDesc actorDesc;
	NxBodyDesc	bodyDesc;

	NxSphereShapeDesc sphereDesc;
	sphereDesc.radius	= 1.5f*scale;
	actorDesc.shapes.pushBack(&sphereDesc);

	actorDesc.body		= NULL;
	actorDesc.globalPose.t	= NxVec3(position.x, position.y, position.z);

	NxActor *pActor = gScene->createActor(actorDesc);
	assert(pActor);
	*/
	// return pActor;

	NxActorDesc actorDesc;
	NxBodyDesc bodyDesc;

	//float height=2.0f;
	//float radius=0.5f;

	// The actor has one shape, a capsule
	NxCapsuleShapeDesc capsuleDesc;

	capsuleDesc.height = 2.0f;
	capsuleDesc.radius = 0.5f;
	actorDesc.shapes.pushBack(&capsuleDesc);
	actorDesc.body		= NULL;
	actorDesc.globalPose.t	= NxVec3(position.x, position.y, position.z);

	NxActor *capsuleActor=gScene->createActor(actorDesc); 
	assert(capsuleActor);
}

void ObjectWide::init(Vector3 position)
{
	float scale=mNode->getScale().x;
	mNode->setScale(scale,scale,scale);
	mNode->pitch(Degree(180));

	//physics part

	NxActorDesc actorDesc;
	NxBodyDesc bodyDesc;
	NxCapsuleShapeDesc capsuleDesc;

	capsuleDesc.height = 2.0f;
	capsuleDesc.radius = 0.5f;
	actorDesc.shapes.pushBack(&capsuleDesc);
	actorDesc.body		= NULL;
	actorDesc.globalPose.t	= NxVec3(position.x, position.y, position.z);

	NxActor *capsuleActor=gScene->createActor(actorDesc); 
	assert(capsuleActor);

}
